package com.production.CoursePlatform.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.production.CoursePlatform.entity.Schedule;
import org.apache.ibatis.annotations.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ScheduleMapper extends BaseMapper<Schedule> {

    // 根据 sID 查询 Schedule 记录
    @Select("SELECT * FROM schedule WHERE sID = #{sID}")
    Schedule findBySID(@Param("sID") int sID);

    // 插入新的 Schedule 记录，不设置 scID
    @Insert("INSERT INTO schedule (sID, Mon1, Mon2, Mon3, Mon4, Mon5, Tues1, Tues2, Tues3, Tues4, Tues5, Wed1, Wed2, Wed3, Wed4, Wed5, Thur1, Thur2, Thur3, Thur4, Thur5, Fri1, Fri2, Fri3, Fri4, Fri5) " +
            "VALUES (#{sID}, #{Mon1}, #{Mon2}, #{Mon3}, #{Mon4}, #{Mon5}, #{Tues1}, #{Tues2}, #{Tues3}, #{Tues4}, #{Tues5}, #{Wed1}, #{Wed2}, #{Wed3}, #{Wed4}, #{Wed5}, #{Thur1}, #{Thur2}, #{Thur3}, #{Thur4}, #{Thur5}, #{Fri1}, #{Fri2}, #{Fri3}, #{Fri4}, #{Fri5})")
    int insertWithoutScID(Schedule schedule);

    // 更新 Schedule 记录
    @Update("UPDATE schedule SET sID = #{sID}, Mon1 = #{Mon1}, Mon2 = #{Mon2}, Mon3 = #{Mon3}, Mon4 = #{Mon4}, Mon5 = #{Mon5}, " +
            "Tues1 = #{Tues1}, Tues2 = #{Tues2}, Tues3 = #{Tues3}, Tues4 = #{Tues4}, Tues5 = #{Tues5}, " +
            "Wed1 = #{Wed1}, Wed2 = #{Wed2}, Wed3 = #{Wed3}, Wed4 = #{Wed4}, Wed5 = #{Wed5}, " +
            "Thur1 = #{Thur1}, Thur2 = #{Thur2}, Thur3 = #{Thur3}, Thur4 = #{Thur4}, Thur5 = #{Thur5}, " +
            "Fri1 = #{Fri1}, Fri2 = #{Fri2}, Fri3 = #{Fri3}, Fri4 = #{Fri4}, Fri5 = #{Fri5} WHERE scID = #{scID}")
    int updateSchedule(Schedule schedule);

    // 删除 Schedule 记录
    @Delete("DELETE FROM schedule WHERE scID = #{scID}")
    int deleteByScID(@Param("scID") int scID);
}

